package cn.codeartist.wechat.qywx.config;

import cn.codeartist.springboot.component.http.bean.RestTemplateFactory;
import cn.codeartist.springboot.component.http.proxy.HttpProxy;
import cn.codeartist.springboot.component.http.proxy.impl.DefaultHttpProxy;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.client.RestTemplate;


/**
 * 应用全局配置
 *
 * @author 艾江南
 * @date 2020/7/28
 */
@Configuration
@EnableCaching
public class ApplicationConfig {

    @Bean
    @Scope(BeanDefinition.SCOPE_PROTOTYPE)
    public RestTemplate restTemplate() {
        return RestTemplateFactory.getTimeoutBean(10_000, 5_000);
    }

    @Bean
    @ConfigurationProperties("qywx")
    public HttpProxy qywxHttpProxy() {
        return new DefaultHttpProxy();
    }
}
